//
// Created by forec on 17-5-1.
//

#ifndef TKDATABASE_UTILS_H_H
#define TKDATABASE_UTILS_H_H

#include <time.h>
#include <stdint.h>
#include <array>
#include <vector>
#include <cstdlib>
#include "../../config/config.h"

void nano_sleep(uint64_t ns);
bool isInitialBallot(int32_t ballot);
bool equal(std::array<int32_t, GROUP_SIZE> & deps1, std::array<int32_t, GROUP_SIZE> & deps2);
bool ValidatePort(const char* flagname, int32_t value);
bool ValidateN(const char* flagname, int32_t value);
bool ValidatePercent(const char * flagname, int32_t value);
bool ValidateSize(const char * flagname, int32_t value);

std::string randStr(int least = MIN_VALUE_SIZE, int most = MAX_VALUE_SIZE);
int32_t randRange(int32_t least, int32_t most);


uint32_t ch_to_int32(unsigned  char* buf);

unsigned  char * int32_to_ch(uint32_t num);


#endif //TKDATABASE_UTILS_H_H
